package com.game;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.game.service.RedissionBusService;
import com.game.utils.Localization;
import com.game.utils.sensitive.SensitiveWords;
import com.game.xmldata.SampleManager;
import com.log.service.GameLogService;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * @author ZGame 容器启动成功后的最后一步回调,主线程运行
 *
 */
@Slf4j
@Component
public class CommandRunner implements CommandLineRunner {
	@Value("${localization.config}")
	private String localizationConfig;// 本地化
	@Value("${logging.config}")
	private String loggingConfig;// 本地log
	@Value("${sensitive.config}")
	private String sensitiveConfig;// 敏感词
	@Value("${xmldata.config}")
	private String xmldataConfig;// xml
	@Autowired
	private GameLogService gameLogService;// 数据库日志
	@Autowired
	private RedissionBusService redissionBusService;// 总线

	@Override
	public void run(String... args) throws Exception {
		// 加载xml数据
		SampleManager.get().init(xmldataConfig);
		log.info("加载xml配置数据完成");
		// 加载敏感词
		SensitiveWords.initAC(sensitiveConfig);
		// 加载本地化翻译
		Localization.getInstance().init(localizationConfig);
		log.info("加载敏感词完成");
		// 启动mongodb日志线程
		gameLogService.start();
		log.info("mongodb数据库日志启动完成");
		// 启动消息总线bus
		redissionBusService.start();
		log.info("消息总线启动完成");
	}
}
